#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>

int gval = 100;

int main(int argc, char* argv[], char *env[]){
  (void)argc;
  (void)argv;
  (void)env;
  pid_t id = fork();
  if(id == 0){
    while(1){
      printf("子：gval: %d, &gval: %p, pid: %d, ppid: %d\n", gval, &gval, getpid(), getppid());
      sleep(1);
      gval++;
    }
  }else{
    while(1){
      printf("父：gval: %d, &gval: %p, pid: %d, ppid: %d\n", gval, &gval, getpid(), getppid());
      sleep(1);

    }
  }
  return 0;
}
